import React, { PureComponent } from 'react';
import { List, ActionSheet, InputItem, Picker, Button, WhiteSpace } from 'antd-mobile';
import { connect } from 'dva';
import { createForm, formShape } from 'rc-form';
import self from './index.less'
let wrapProps;
if (new RegExp('\\biPhone\\b|\\biPod\\b', 'i').test(window.navigator.userAgent)) {
    wrapProps = {
        onTouchStart: e => e.preventDefault(),
    };
}
class UserInformation extends PureComponent {
    state = {
        type: 'money',
    }
    constructor(props, context) {
        super(props, context)
        this.state = {
            self: {}
        }
    }
    componentWillMount() {
        this.props.dispatch({ type: "teacherInformation/getUserInfo", payload: {} })
        this.props.dispatch({ type: "teacherInformation/getUserNation", payload: {} })
        this.props.dispatch({ type: "teacherInformation/loadBasePeopleList", payload: {} })
    }
    test() {
        this.props.dispatch({ type: "auth/redirect", payload: { url: "/stuIndex" } })
    }
    // cycle
    render() {
        const { type } = this.state;
        const { Item } = List, { Brief } = Item;
        this.props.user == "" ? null : this.setState({ self: this.props.user })
        return (
            <div className="self">
                <img style={{ display: "block", margin: "auto", width: "100%" }} src={`http://172.25.253.114:28080/km-gradms-core-server/info/infoPhoto/showImgByPersonId?personId=${this.state.self.id}&photoType=4`} />
                <InputItem type={type} value={this.state.self.perName} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >姓名</InputItem>
                <InputItem type={type} value={this.state.self.nameSpell} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, nameSpell: v } })}
                    moneyKeyboardAlign="right" >拼音名</InputItem>
                <InputItem type={type} value={this.state.self.orgCode} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, orgCode: v } })}
                    moneyKeyboardAlign="right" >院系</InputItem>
                {
                    this.props.nation.length == 0 ? null :
                        <Picker
                            data={this.props.nation}
                            title="请选择国别"
                            cascade={false}
                            extra="请选择国别"
                            value={this.state.self.nationCode}
                            onChange={v => this.setState({ self: { ...this.state.self, nationCode: v } })}
                            onOk={v => this.setState({ self: { ...this.state.self, nationCode: v } })}
                        >
                            <List.Item arrow="horizontal">国别</List.Item>
                        </Picker>
                }
                <InputItem type={type} value={this.state.self.genderCode} disabled placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >性别</InputItem>
                <InputItem type={type} value={this.state.self.perBirthday} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >出生年月</InputItem>
                <InputItem type={type} value={this.state.self.perNativePlace} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >籍贯</InputItem>
                <InputItem type={type} value={this.state.self.marryState} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >婚否</InputItem>
                <InputItem type={type} value={this.state.self.EMAIL} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >邮箱</InputItem>
                {this.props.nationality == "" ? null :
                    <Picker title="请选择民族"
                        data={this.props.nationality}
                        cascade={false}
                        extra="请选择民族"
                        value={this.state.self.peopleCode}
                        onChange={v => this.setState({ self: { ...this.state.self, peopleCode: v } })}
                        onOk={v => this.setState({ self: { ...this.state.self, peopleCode: v } })}
                    >
                        <List.Item arrow="horizontal">民族</List.Item>
                    </Picker>
                }
                <InputItem type={type} value={this.state.self.cardTypeCode} disabled placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >证件类型</InputItem>
                <InputItem type={type} value={this.state.self.cardNum} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >证件号</InputItem>
                <InputItem type={type} value={this.state.self.perAddress} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >通讯地址</InputItem>
                <InputItem type={type} value={this.state.self.mobilePhone} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >移动电话</InputItem>
                <InputItem type={type} value={this.state.self.famillyAddress} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >家庭地址</InputItem>
                <InputItem type={type} value={this.state.self.famTelephone} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >家庭电话</InputItem>
                <InputItem type={type} value={this.state.self.perOneCardNum} placeholder="英文名" clear onChange={v => this.setState({ self: { ...this.state.self, perName: v } })}
                    moneyKeyboardAlign="right" >一卡通号</InputItem>

            </div>
        );
    }
}
function mapStateToProps(state) {
    return {
        user: state.teacherInformation.user,
        nation: state.teacherInformation.nation,
        nationality: state.teacherInformation.nationality
    }
}
export default connect(mapStateToProps)(UserInformation);
